﻿using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.ObjectModel;
using HigLabo.Net.Extensions;

namespace HigLabo.Net.WindowsLive
{
    /// <summary>
    /// 
    /// </summary>
    public class TagCollection : Collection<Tag>
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        public TagCollection(String jsontext)
        {
            this.SetProperty(jsontext);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsontext"></param>
        private void SetProperty(String jsontext)
        {
            var d = Common.SetData(jsontext).ToString("data");
            var cc = JsonConvert.DeserializeObject(d) as JContainer;

            foreach (var s in WindowsLiveClient.CreateJsonTextList(cc))
            {
                this.Add(new Tag(s));
            }
        }
    }
}
